package com.renjiyue.GUI;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class GUIDome01 {
    public static void main(String[] args) {
        Frame frame = new Frame();
        Panel panel1 = new Panel();
        //设置布局
        frame.setLayout(null);
        //坐标 这里设置的坐标（300,300）是相对于整个屏幕
        frame.setBounds(300,300,500,500);
        //颜色是RGB的，可调
        frame.setBackground(new Color(0x2020BB));
        //panel设置坐标，相对于frame
        panel1.setBounds(50,50,400,400);
        panel1.setBackground(new Color(193,15,60));
        //把Panel容器装入Frame容器中，使其能在Freme窗口中显示出来
        //frame.add(panel)
        frame.add(panel1);

        frame.setVisible(true);
        //监听事见，监听窗口关闭事见 System.exit(0)
        //适配器模式：
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }
}